import { createRouter, createWebHistory } from 'vue-router';
import IndexPage from '../views/IndexPage.vue';
import BusinessList from '../views/BusinessList.vue';
import OrderList from '../views/OrderList.vue';
import LoginPage from '../views/LoginPage.vue';
import BusinessInfo from '../views/BusinessInfo.vue';
import UserAddress from '../views/UserAddress.vue';
import AddUserAddress from '../views/AddUserAddress.vue';
import EditUserAddress from '../views/EditUserAddress.vue';
import RegisterPage from '../views/RegisterPage';
import OrderPage from '../views/OrderPage.vue';
import PaymentPage from '../views/PaymentPage.vue';
import UserCenter from '../views/UserCenter.vue';
import AccountManagement from '../views/AccountManagement.vue';
import UserCart from '../views/UserCart.vue';
import UserCouponPackage from '../views/UserCouponPackage.vue';
import UserScore from '../views/UserScore.vue';
import UserVip from '../views/UserVip.vue';
import FindPage from '../views/FindPage.vue';
import PayDone from '../views/PayDone.vue';
import BuyCoupon from'../views/BuyCoupon.vue';
import OpenVip from'../views/OpenVip.vue';
import TestLocation from '../views/TestLocation.vue';
import LocationSearch from '../views/LocationSearch.vue';
import ErrorPage403 from '../components/ErrorPage403.vue';
import ErrorPage504 from '../components/ErrorPage504.vue';
import CheckPage from '../views/CheckPage.vue';
import Consultation from '../views/ConsultationPage.vue';


const routes = [
  {
    path: '/',
    name: 'Home',
    component: IndexPage
  },
  {
    path: '/index',
    name: 'Index',
    component: IndexPage
  },
  {
    path: '/businessList',
    name: 'BusinessList',
    component: BusinessList
  },
  {
    path:'/businessInfo',
    name:'BusinessInfo',
    component: BusinessInfo
  },
  {
    path:'/orders',
    name:'Orders',
    component: OrderPage
  },
  {
    path:'/payment',
    name:'Payment',
    component: PaymentPage
  },
  {
    path:'/orderList',
    name:'OrderList',
    component: OrderList
  }
  ,{
    path:'/login',
    name:'Login',
    component: LoginPage
  },
  {
    path:'/register',
    name:'Register',
    component: RegisterPage
  },
  {
    path:'/businessInfo',
    name:'BusinessInfo',
    component: BusinessInfo
    },
  {
    path:'/userAddress',
    name:'UserAddress',
    component: UserAddress
  },
  {
    path:'/addUserAddress',
    name:'AddUserAddress',
    component: AddUserAddress
  },
  {
    path:'/editUserAddress',
    name:'EditUserAddress',
    component: EditUserAddress
  },
  {
    path:'/userCenter',
    name:'UserCenter',
    component: UserCenter
  },
  {
    path:'/accountManagement',
    name:'AccountManagement',
    component: AccountManagement
  },
  {
    path:'/userCart',
    name:'UserCart',
    component: UserCart
  },
  {
    path:'/userCouponPackage',
    name:'UserCouponPackage',
    component: UserCouponPackage
  },
  {
    path:'/userScore',
    name:'UserScore',
    component: UserScore
  },
  {
    path:'/userVip',
    name:'UserVip',
    component: UserVip
  },
  {
    path:'/findPage',
    name:'FindPage',
    component: FindPage
  },
  {
    path:'/payDone',
    name:'PayDone',
    component: PayDone
  },
  {
    path:'/buyCoupon',
    name:'BuyCoupon',
    component: BuyCoupon
  },
  {
    path:'/openVip',
    name:'OpenVip',
    component: OpenVip
  },
  {
    path:'/testLocation',
    name:'TestLocation',
    component: TestLocation
  },
  {
    path:'/locationSearch',
    name:'LocationSearch',
    component:LocationSearch
  },
  {
    path:'/error403',
    name:'ErrorPage403',
    component:ErrorPage403
  },
  {
    path:'/error504',
    name:'ErrorPage504',
    component:ErrorPage504
  },
  {
    path:'/check',
    name:'CheckPage',
    component:CheckPage
  },
  {
    path:'/consultation',
    name:'Consultation',
    component: Consultation
  }
];

//创建路由实例
const router = createRouter({
  history: createWebHistory(),
  routes
});

// 保存原始的 push 函数
const originalPush = router.push;

// 重写 push 函数 使用 originalPush.call(this, location) 调用原始的 push 函数
// 并使用 catch 方法来捕获可能的异常
router.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

export default router;


